{% macro listPackages(packages, paginate, showAutoUpdateWarning, meta) %}
    <ul class="packages list-unstyled">
        {% for package in packages|filter(package => package.replacementPackage|default('') != 'spam/spam') %}
            {% if package.id is numeric %}
                {% set packageUrl = path('view_package', { 'name' : package.name }) %}
            {% else %}
                {% set packageUrl = path('view_providers', { 'name' : package.name }) %}
            {% endif %}
            <li data-url="{{ packageUrl }}" class="row">
                <div class="col-xs-12 package-item">
                    <div class="row">
                        <div class="col-sm-9 col-lg-10">
                            {% if package.language is defined and package.language is not empty %}<p class="pull-right language">{{ package.language }}</p>{% endif %}
                            <h4 class="font-bold">
                                <a href="{{ packageUrl }}">{{ package.name }}</a>
                                {% if package.id is not numeric %}
                                    <small>(Virtual Package)</small>
                                {% endif %}
                                {% if not package.abandoned|default(false) %}
                                    {% if showAutoUpdateWarning and '://github.com/' in package.repository and package.getAutoUpdated() == 1 %}
                                        <small>(Legacy Auto-Update, Needs Attention)</small>
                                    {% elseif showAutoUpdateWarning and '://github.com/' in package.repository and package.getAutoUpdated() == 0 %}
                                        <small>(Not Auto-Updated, Needs Attention)</small>
                                    {% elseif showAutoUpdateWarning and not package.isAutoUpdated() %}
                                        <small>(Not Auto-Updated)</small>
                                    {% endif %}
                                {% endif %}
                            </h4>
                            {% if package.description is defined and package.description %}
                                <p>{{ package.description }}</p>
                            {% endif %}
                            {% if package.abandoned|default(false) %}
                                <p class="abandoned">
                                    <i class="glyphicon glyphicon-exclamation-sign"></i> Abandoned! {% if package.replacementPackage %}See <a href="{{ '://' in package.replacementPackage ? package.replacementPackage : path('view_package', {name: package.replacementPackage}) }}">{{ package.replacementPackage }}</a>{% endif %}
                                </p>
                            {% endif %}
                        </div>
                        <div class="col-sm-3 col-lg-2">
                            {% if meta %}
                                <p class="metadata">
                                    <span class="metadata-block"><i class="glyphicon glyphicon-download"></i> {{ meta.downloads[package.id]|default(0)|number_format(0, '.', '&#8201;')|raw }}</span>
                                    <span class="metadata-block"><i class="glyphicon glyphicon-star"></i> {{ meta.favers[package.id]|default(0)|number_format(0, '.', '&#8201;')|raw }}</span>
                                </p>
                            {% endif %}
                        </div>
                    </div>
                </div>
            </li>
        {% endfor %}
    </ul>

    {% if paginate is defined and paginate and packages.haveToPaginate() %}
        {{ pagerfanta(packages, 'twitter_bootstrap', {'proximity': 2}) }}
    {% endif %}
{% endmacro %}

{% macro listPackagesShort(packages, showVersion, showMoreUrl) %}
    <ul class="list-unstyled">
        {% for package in packages %}
            <li>
                <a href="{{ path('view_package', {'name' : package.name }) }}">{{ package.name }}{% if showVersion is defined and showVersion %}<strong>{{ package.version }}</strong>{% endif %}</a>
                {{ package.description|truncate(60) }}
            </li>
        {% endfor %}
        {% if showMoreUrl is defined and showMoreUrl %}
            <li><a href="{{ path('browse_popular') }}">See more...</a></li>
        {% endif %}
    </ul>
{% endmacro %}

{% macro packageLink(packageName, type) %}
    {%- if type == 'provide' -%}
        <a href="{{ path('view_providers', { 'name': packageName }) }}">{{ packageName }}</a>
    {%- elseif packageName is existing_package -%}
        <a href="{{ path('view_package', { 'name': packageName }) }}">{{ packageName }}</a>
    {%- elseif packageName is existing_provider -%}
        <a href="{{ path('view_providers', { 'name': packageName }) }}">{{ packageName }}</a>
    {%- else -%}
        {{ packageName }}
    {%- endif -%}
{% endmacro %}
